package com.lw.ssm.controller.advice;

import com.lw.ssm.dto.R;
import com.lw.ssm.exceptions.MyBaseException;
import com.lw.ssm.utils.ResultCode;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author Administrator
 * @version 1.0
 * @description:
 * @date 2022/3/10 21:31
 */
@ControllerAdvice
public class MyExceptionAdvice {

    @ExceptionHandler(MyBaseException.class)
    public R processException(MyBaseException e){
        return R.setError(ResultCode.DATA_EMPTY,e.getMessage(),null);
    }

    @ExceptionHandler(Exception.class)
    public R processException(Exception e){
        return R.setError(ResultCode.FAIL,e.getMessage(),null);
    }
}
